package UI;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/insert")
public class StuInsertData extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
                req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        writer.write("<!doctype html>");
        writer.write("<html>");
        writer.write("<head>");
        writer.write("<meta charset='utf-8'>");
        writer.write("</head>");
        writer.write("<h1>学生信息添加展示</h1>");
        writer.write("<body style='backgroud:#ccffff;'>");
        writer.write("<h1>学生信息展示</h1>");
        writer.write("<div style='margin:0 auto;width:600px;border:solid 3px red;'>" +
                "<h3><a href='insert'>录入信息</a></h3>");
        writer.write("<form action='insertok' methon='post'>" +
                "姓名:<input type='text' name='name'><br>" +
                "性别:<input type='text' name='sex'><br>" +
                "年龄:<input type='text' name='age'><br>" +
                "专业:<input type='text' name='major'><br>" +
                "时间:<input type='text' name='time'><br>" +
                "<button>提交</button>" +
                "<input type='reset' value='重置'/>" +
                "</form>" +
                "</div>");
        writer.write("</body>");
        writer.write("</html>");
    }
}
